<%@ page import="java.sql.*, studentportal.*"%>

<html>

<head>
 
<title>Student Portal</title>
<meta name="Microsoft Theme" content="indust 011">
</head>

<body background="indtextb.jpg" bgcolor="#FFFFFF" text="#000000" link="#3366CC" vlink="#666666" alink="#996600">

<!--mstheme--><font face="Trebuchet MS, Arial, Helvetica"><!--mstheme--></font>

<table border="0" width="100%">
  <tr>
    <td width="100%"><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica"><img border="0" src="StdPrtlbanner.jpg" width="846" height="65">&nbsp;<!--mstheme--></font></td>
  </tr>
</table>
<!--mstheme--><font face="Trebuchet MS, Arial, Helvetica"><!--mstheme--></font>
<table border="0" width="100%">
  <tr>
    <td width="23%">
      <!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">
      <p align="center"><a href="AdminAdmissionHome.html">Admissions</a><!--mstheme--></font></td>
    <td width="23%">
      <!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">
      <p align="center"><a href="AdminStudentHome.html">Students</a><!--mstheme--></font></td>
    <td width="23%">
      <!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">
      <p align="center"><a href="AdminFacultyHome.html">Faculties</a><!--mstheme--></font></td>

    <td width="20%">
      <!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">
      <p align="center"><a href="AdminNotificaiton.jsp">Notifications</a><!--mstheme--></font></td>

    <td width="20%">
      <!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">
      <p align="center"><a href="AdvertisementView.jsp">Examination</a><!--mstheme--></font></td>

    <td width="20%">
      <!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">
      <p align="center"><a href="AdminBranchHome.html">Branches</a><!--mstheme--></font></td>

    <td width="20%">
      <!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">
      <p align="center"><a href="AdminBooksHome.html">Books</a><!--mstheme--></font></td>
    <td width="20%">
      <!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">
      <p align="center"><a href="AdminCourseHome.html">Courses</a><!--mstheme--></font></td>

    <td width="20%">
      <!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">
      <p align="center"><a href="AdminSemesterHome.html">Semesters</a><!--mstheme--></font></td>

    <td width="20%">
      <!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">
      <p align="center"><a href="AdminSubjectHome.html">Subjects</a><!--mstheme--></font></td>

    <td width="20%">
      <!--mstheme--><font face="Trebuchet MS, Arial, Helvetica"><a href="AdminDesignationHome.html">Designation</a><!--mstheme--></font></td>

	  <td width="20%">
      <!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">
      <p align="center"><a href="Home.html">Home</a><!--mstheme--></font></td>
  </tr>
</table>

<!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">


<font face="Trebuchet MS, Arial, Helvetica">
	<form method="POST" action="">
  
	  <p>
            &nbsp;<!--mstheme--></font>
			<table align="center" border="0">
				<tr>
					<th><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">Student ID<!--mstheme--></font></th>
					<th><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">Student Name<!--mstheme--></font></th>
					<th><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">Student Address<!--mstheme--></font></th>
					<th><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">Student DOB<!--mstheme--></font></th>
					<th><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">Student Phone<!--mstheme--></font></th>
					<th><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">Student Email<!--mstheme--></font></th>
					<th><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">Student
                      Admission Date<!--mstheme--></font></th>
					<th><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">Student Login Name<!--mstheme--></font></th>
					<th><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">Student Reg Status<!--mstheme--></font></th>
					<th><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">Student Course<!--mstheme--></font></th>
					<th><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">Update Status<!--mstheme--></font></th>
					<th><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">Delete<!--mstheme--></font></th>
				</tr>
				<%
					Connection con=MySQLDriver.getConnection(); 
					Statement st=null;
					ResultSet rs=null;
				 
					String stuid=request.getParameter("sid");
					String stustatus=request.getParameter("status");
					String delStatus=request.getParameter("delStatus");
					if(delStatus==null && stuid!=null && stustatus!=null)
					{
						st=con.createStatement();
						int i=0;
						rs=st.executeQuery("select count(*) from student_login where student_id="+stuid);
						if(rs.next())
						  i=rs.getInt(1);
						rs.close();
						st.close();
						
											if(i==0)
											{
												st=con.createStatement();
												rs=st.executeQuery("select * from student_master where student_id='"+request.getParameter("sid")+"'");
												rs.next();
												String sid=rs.getString(1);
												java.sql.Date sdoj=rs.getDate(7);
												String sname=rs.getString(8);
												rs.close();
												st.close();
												st=con.createStatement();
												String qr="insert into student_login values('"+sid+"','"+sname+"','"+sname+"','"+sname+"','"+sdoj+"')";
												System.out.println(qr);
												int j=st.executeUpdate(qr);
												st.close();
											}
						st=con.createStatement();
						if(stustatus.equals("Yes"))
							i=st.executeUpdate("update student_master set student_login_status='No'  where student_id='"+request.getParameter("sid")+"'");
						else 
							i=st.executeUpdate("update student_master set student_login_status='Yes'  where student_id='"+request.getParameter("sid")+"'");
						st.close();
						
					}else if(delStatus!=null) {
						st=con.createStatement();
						st.executeUpdate("delete from student_login where student_id="+stuid);
						st.close();
						st=con.createStatement();
						st.executeUpdate("delete from student_master where student_id="+stuid);
						st.close();
					}
					st=con.createStatement();
					rs=st.executeQuery("select * from student_master order by student_id asc");
					System.out.println("Hi");
					if(rs!=null)
					{
						while(rs.next())
						{
								System.out.println("In While");
								String sid=rs.getString(1);

				%>
					
						<tr>
							<td align="center"><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica"><%=sid%><!--mstheme--></font></td>
							<td align="center"><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica"><%=rs.getString(2)%><!--mstheme--></font></td>
							<td align="center"><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica"><%=rs.getString(3)%><!--mstheme--></font></td>
							<td align="center"><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica"><%=rs.getDate(4)%><!--mstheme--></font></td>
							<td align="center"><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica"><%=rs.getString(5)%><!--mstheme--></font></td>
							<td align="center"><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica"><%=rs.getString(6)%><!--mstheme--></font></td>
							<td align="center"><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica"><%=rs.getDate(7)%><!--mstheme--></font></td>
							<td align="center"><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica"><%=rs.getString(8)%><!--mstheme--></font></td>
							<%String status=rs.getString(9);%>
							<td align="center"><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica"><%=status%><!--mstheme--></font></td>
							<td align="center"><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica"><%=rs.getString(10)%><!--mstheme--></font></td>
							<td align="center"><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica"><a href="NewStudentRegStatus?sid=<%=rs.getString(1)%>&status=<%=status%>">Update Status</a><!--mstheme--></font></td>
							<td align="center"><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica"><a href="NewStudentRegStatus?sid=<%=rs.getString(1)%>&status=<%=status%>&delStatus=yes">Delete</a><!--mstheme--></font></td>
						</tr>
					
				<%
					
					}
					rs.close();
					st.close();
					con.close();
					}
					else
					{
				%>
					<tr>
							<td align="center" colspan="10"><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">There is No New Students<!--mstheme--></font></td>
					</tr>
							
				<%
					}						
				%>
				
				</table>
    <!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">
	</form>
</font>

<!--mstheme--></font>

</body>

</html>
